package com.moore.controller;

import com.moore.bean.Message;
import com.moore.dto.ResponseData;
import com.moore.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import static com.moore.utils.Logger.toLog;

@Controller
@RequestMapping("/message")
public class MessageController {
    @Autowired
    private MessageService messageService;

    @RequestMapping("/get")
    @ResponseBody
    public ResponseData getMessage(@RequestBody Message message) {
        String tenant = message.getTenant();
        String status = message.getStatus();
        toLog("正在获取消息");
        return messageService.getMessage(tenant,status);
    }

    @RequestMapping("update")
    @ResponseBody
    public ResponseData updateMessage(@RequestBody Message message) {
        long id = message.getId();
        String status = message.getStatus();
        toLog("正在更新消息");
        return messageService.isRead(status,id);
    }
}
